﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.Services;
using System.Data.SqlClient;
using System.Data;
using System.Web.Security;

/// <summary>
///PlanSystemToOA 的摘要说明
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
//若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务，请取消对下行的注释。 
// [System.Web.Script.Services.ScriptService]
public class PlanSystemToOA : System.Web.Services.WebService
{

    public PlanSystemToOA()
    {

        //如果使用设计的组件，请取消注释以下行 
        //InitializeComponent(); 
    }

    /// <summary>
    /// OA 更新密码时同步更新计划系统密码的web服务
    /// </summary>
    /// <param name="ItCode">OA和计划系统的关联码</param>
    /// <param name="Password">密码值,加密后的值，密文只包括密码内容.</param>
    /// <returns>标识字符串，成功为True，失败为False</returns>
    [WebMethod]
    public string UpdateItCodePassWord(string ItCode, string Password)
    {
        //如果将密码值加密后传递过来，则调用解密方法。没有加密的话直接将明文加密为MD5存入。
        //string pwd = OACommon.OAEncrypt.DEcrypt(Password);
        string pwd = Password;
        //string sql = "update DS_UserInfo set UserPassWord='" + FormsAuthentication.HashPasswordForStoringInConfigFile(pwd, "MD5") + "' where ItCode='" + ItCode+"'";
        string sql = "update DS_UserInfo set UserPassWord='" +pwd + "' where ItCode='" + ItCode + "'";
        if (DAL.SqlHelper.ExecuteNonQuery(DAL.SqlHelper.connStr, CommandType.Text, sql) > 0)
        {
            return "true";
        }
        else
        {
            return "false";
        }
    }

}

